﻿<Serializable()>
Public Class OrderCriterion

    Enum SortDirection
        ASC = 0
        DESC = 1
    End Enum

    Public Property Expression() As String

    Public Property Direction() As SortDirection

    Public Sub New(ByVal expression As String)
        Me.Expression = expression
        Me.Direction = SortDirection.ASC
    End Sub

    Public Sub ToggleDirection()
        If Direction = SortDirection.ASC Then
            Direction = SortDirection.DESC
        Else
            Direction = SortDirection.ASC
        End If
    End Sub

    Public Overrides Function ToString() As String
        Return String.Format("{0} {1}", Expression, Direction.ToString)
    End Function

End Class
